﻿using Nop.Admin.Models.Common;
using Nop.Core.Domain.Shipping;
using Nop.Web.Framework.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Nop.Admin.Models.Logistics
{
    public class PlanNoteModel : BaseNopEntityModel
    {
        public PlanNoteModel()
        {
            string note_ = String.Empty;
        }

        private string note_;

        public int PlanId { get; set; }

        public int? LocationId { get; set; }

        public string Note 
        {
            get
            {
                return note_;
            }
            
            set
            {
                note_ = value;

                var splitNote = Note.Split(new char[] { '|' });
                Action = splitNote[0];
                PlanStatus = Int32.Parse(splitNote[1]);
                CustomerId = Int32.Parse(splitNote[2]);

                if (splitNote.Count() > 3)
                {
                    PackageId = Int32.Parse(splitNote[3]);
                    PackageStatus = Int32.Parse(splitNote[4]);
                }
            }
        }

        public bool ValidForCommission { get; set; }

        public bool DisplayToCourier { get; set; }

        public string CreatedOn { get; set; }

        #region Breakdown of Note field

        public string Action { get; set; }
        public int PlanStatus { get; set; }
        public int CustomerId { get; set; }
        public int? PackageId { get; set; }
        public int? PackageStatus { get; set; }

        #endregion
    }
}